<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>电信套餐订购系统 - 登录注册</title>
    <!-- 引入项目现有的CSS -->
    <link rel="stylesheet" href="./css/github-markdown-light.css">
    <style>
        body {
            margin: 0;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
            background-color: #f6f8fa;
            color: #1f2328;
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .container {
            width: 100%;
            max-width: 400px;
            margin: 20px;
            padding: 25px;
            border: 1px solid #d1d9e0;
            border-radius: 8px;
            background: #ffffff;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        
        .form-header {
            text-align: center;
            margin-bottom: 25px;
        }
        
        .form-header h2 {
            margin: 0;
            font-size: 24px;
            color: #1f2328;
        }
        
        .form-container {
            display: flex;
            flex-direction: column;
        }
        
        .form-group {
            margin-bottom: 15px;
        }
        
        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: 500;
            color: #1f2328;
        }
        
        .form-group input {
            width: 100%;
            padding: 8px 12px;
            font-size: 14px;
            border: 1px solid #d1d9e0;
            border-radius: 6px;
            box-sizing: border-box;
            background-color: #ffffff;
            color: #1f2328;
        }
        
        .form-group input:focus {
            outline: none;
            border-color: #0969da;
            box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
        }
        
        .form-button {
            width: 100%;
            padding: 10px 16px;
            font-size: 14px;
            font-weight: 500;
            color: #ffffff;
            background-color: #0969da;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            transition: background-color 0.2s ease;
        }
        
        .form-button:hover {
            background-color: #0758b5;
        }
        
        .form-button:active {
            background-color: #064aa3;
        }
        
        .form-toggle {
            margin-top: 15px;
            text-align: center;
            font-size: 14px;
        }
        
        .form-toggle a {
            color: #0969da;
            text-decoration: none;
        }
        
        .form-toggle a:hover {
            text-decoration: underline;
        }
        
        .form-divider {
            margin: 20px 0;
            text-align: center;
            position: relative;
        }
        
        .form-divider::before {
            content: "";
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 1px;
            background-color: #d1d9e0;
        }
        
        .form-divider span {
            position: relative;
            padding: 0 10px;
            background-color: #ffffff;
            color: #818b98;
            font-size: 12px;
        }
        
        .error-message {
            color: #d1242f;
            font-size: 12px;
            margin-top: 5px;
        }
        
        .form-switch {
            display: flex;
            justify-content: center;
            margin-bottom: 20px;
        }
        
        .form-switch button {
            padding: 8px 16px;
            font-size: 14px;
            border: 1px solid #d1d9e0;
            background-color: #ffffff;
            color: #1f2328;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .form-switch button:first-child {
            border-right: none;
            border-radius: 6px 0 0 6px;
        }
        
        .form-switch button:last-child {
            border-radius: 0 6px 6px 0;
        }
        
        .form-switch button.active {
            background-color: #0969da;
            color: #ffffff;
            border-color: #0969da;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="form-header">
            <h2>电信套餐订购系统</h2>
        </div>
        
        <div class="form-switch">
            <button id="loginTab" class="active" onclick="switchForm('login')">登录</button>
            <button id="registerTab" onclick="switchForm('register')">注册</button>
        </div>
        
        <div id="loginForm" class="form-container">
            <div class="form-group">
                <label for="loginUsername">用户名</label>
                <input type="text" id="loginUsername" placeholder="请输入用户名">
            </div>
            
            <div class="form-group">
                <label for="loginPassword">密码</label>
                <input type="password" id="loginPassword" placeholder="请输入密码">
            </div>
            
            <button id="loginButton" class="form-button" onclick="login()">登录</button>
            
            <div class="form-toggle">
                <a href="#" onclick="switchForm('register'); return false;">还没有账号？立即注册</a>
            </div>
        </div>
        
        <div id="registerForm" class="form-container" style="display: none;">
            <div class="form-group">
                <label for="registerUsername">用户名</label>
                <input type="text" id="registerUsername" placeholder="请设置用户名">
            </div>
            
            <div class="form-group">
                <label for="registerPassword">密码</label>
                <input type="password" id="registerPassword" placeholder="请设置密码">
            </div>
            
            <div class="form-group">
                <label for="confirmPassword">确认密码</label>
                <input type="password" id="confirmPassword" placeholder="请再次输入密码">
            </div>

            <div class="form-group">
                <label for="registerEmail">邮箱</label>
                <input type="text" id="registerEmail" placeholder="请设置邮箱">
            </div>

             <div class="form-group">
                <label for="registerPhone">手机号</label>
                <input type="text" id="registerPhone" placeholder="请设置手机号">
            </div>
            
            <button id="registerButton" class="form-button" onclick="register()">注册</button>
            
            <div class="form-toggle">
                <a href="#" onclick="switchForm('login'); return false;">已有账号？返回登录</a>
            </div>
        </div>
    </div>

    <script>
        // 切换登录和注册表单
        function switchForm(formType) {
            const loginForm = document.getElementById('loginForm');
            const registerForm = document.getElementById('registerForm');
            const loginTab = document.getElementById('loginTab');
            const registerTab = document.getElementById('registerTab');
            
            if (formType === 'login') {
                loginForm.style.display = 'flex';
                registerForm.style.display = 'none';
                loginTab.classList.add('active');
                registerTab.classList.remove('active');
            } else {
                loginForm.style.display = 'none';
                registerForm.style.display = 'flex';
                loginTab.classList.remove('active');
                registerTab.classList.add('active');
            }
        }
        
        // 登录功能
        function login() {
            const username = document.getElementById('loginUsername').value.trim();
            const password = document.getElementById('loginPassword').value.trim();
            
            // 简单的表单验证
            if (!username || !password) {
                alert('请输入用户名和密码');
                return;
            }
            
            // 根据用户名判断跳转页面
            // 如果用户名为admin，跳转到管理员主页面
            // 否则跳转到普通用户页面
            if (username === 'admin'&&password==='fD1bD@2hA5aR0') {
                window.location.href = 'admin_dashboard.html';
            } else if (username === 'user'&&password==='fD1bD@2hA5aR0'){
                window.location.href = 'user_dashboard.html';
            }else{
                alert('用户名或密码错误');
            }
        }
        
        // 注册功能
        function register() {
            const username = document.getElementById('registerUsername').value.trim();
            const password = document.getElementById('registerPassword').value.trim();
            const confirmPassword = document.getElementById('confirmPassword').value.trim();
            
            // 简单的表单验证
            if (!username || !password || !confirmPassword) {
                alert('请填写所有必填字段');
                return;
            }
            
            if (password !== confirmPassword) {
                alert('两次输入的密码不一致');
                return;
            }
            
            // 这里可以添加实际的注册逻辑
            // 为了演示，注册成功后切换到登录表单
            alert('注册成功，请登录');
            switchForm('login');
        }
        
        // 为表单添加回车登录/注册功能
        document.getElementById('loginUsername').addEventListener('keydown', function(e) {
            if (e.key === 'Enter') {
                document.getElementById('loginPassword').focus();
            }
        });
        
        document.getElementById('loginPassword').addEventListener('keydown', function(e) {
            if (e.key === 'Enter') {
                login();
            }
        });
        
        document.getElementById('registerUsername').addEventListener('keydown', function(e) {
            if (e.key === 'Enter') {
                document.getElementById('registerPassword').focus();
            }
        });
        
        document.getElementById('registerPassword').addEventListener('keydown', function(e) {
            if (e.key === 'Enter') {
                document.getElementById('confirmPassword').focus();
            }
        });
        
        document.getElementById('confirmPassword').addEventListener('keydown', function(e) {
            if (e.key === 'Enter') {
                register();
            }
        });
    </script>
</body>
</html>